
import matplotlib.pyplot as plt
import numpy as np

# grid()方法设置图表中的网格线
def fun1():
    x = np.array([1, 2, 3, 4])
    y = np.array([1, 4, 9, 16])

    plt.title("Python grid() Test")
    plt.xlabel("x - label")
    plt.ylabel("y - label")

    plt.plot(x, y)
    # plt.grid()
    plt.grid(axis='x')
    plt.show()

# grid(color = 'color', linestyle = 'linestyle', linewidth = number)
def fun2():
    x = np.array([1, 2, 3, 4])
    y = np.array([1, 4, 9, 16])

    plt.title("Python grid() Test")
    plt.xlabel("x - label")
    plt.ylabel("y - label")

    plt.plot(x, y)
    plt.grid(color = 'r', linestyle = '--', linewidth=0.5)

    plt.show()

if __name__ == '__main__':
    fun2()